<template>
  <div class="about">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
          <div class="layui-card">
            <div class="layui-card-header">换绑设备</div>
            <div class="layui-card-body" pad15="">
              <div class="layui-form" lay-filter="">
                <div class="layui-form-item">
                  <label class="layui-form-label">旧设备序列号</label>
                  <div class="layui-input-inline">
                    <input type="text" name="oldIMEI" v-model="oldIMEI" lay-verify="required" lay-vertype="tips" class="layui-input">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">新设备序列号</label>
                  <div class="layui-input-inline">
                    <input type="text" name="newIMEI"  v-model="newIMEI" lay-verify="pass" lay-vertype="tips" autocomplete="off" id="LAY_password" class="layui-input">
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="setmypass" @click="submitDate" v-loading="加载中" >确认换绑</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import md5 from 'js-md5';
export default {
  components: {},
  data() {
    return {
      oldIMEI: "",
      newIMEI: "",
      加载中: false,
    };
  },
  methods: {
    submitDate: function () {
      var T = this;

      var str=T.oldIMEI;
      var str1=T.newIMEI;
      if(str.length <8||str1.length <8){
        T.$XModal.message('请输入正确的设备序列号',{status:'error'});
        return;
      }
      var params={
        oldIMEI:T.oldIMEI,
        newIMEI:T.newIMEI,
      }
      T.加载中=true
      this.$请求('/exchange/device',params,function(result){
         if(result.data.code!==1){
           T.加载中=false
           T.$XModal.message(result.data.message,{status:'error'});
           return;
         }else{
           T.加载中=false
           T.$XModal.message('换绑成功',{status:'success'});
           return;
         }
      })
    },
  },
};
</script>
<style scoped>
.layui-form-item{
  text-align: center;
}
.layui-form-item label {
  width: 100px;
}
</style>
